package com.xiaoyu.lingdian.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;
import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.service.CoreMyButlerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CoreMyButler;

@Service("coreMyButlerService")
public class CoreMyButlerServiceImpl implements CoreMyButlerService {

	@Autowired
	private MyBatisDAO myBatisDAO;

	@Override
	public boolean insertCoreMyButler(CoreMyButler coreMyButler) {
		myBatisDAO.insert(coreMyButler);
		return true;
	}

	@Override
	public boolean updateCoreMyButler(CoreMyButler coreMyButler) {
		myBatisDAO.update(coreMyButler);
		return true;
	}

	@Override
	public boolean deleteCoreMyButler(CoreMyButler coreMyButler) {
		myBatisDAO.delete(coreMyButler);
		return true;
	}

	private static final String DELETEBATCH_COREMYBUTLER_BY_IDS="deleteBatchCoreMyButlerByIds";
	@Override
	public boolean deleteBatchByIds(List<String> list ) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETEBATCH_COREMYBUTLER_BY_IDS,hashMap);
		return true;
	}

	@Override
	public CoreMyButler getCoreMyButler(CoreMyButler coreMyButler) {
		return (CoreMyButler) myBatisDAO.findForObject(coreMyButler);
	}

	private static final String FIND_COREMYBUTLER_FOR_LISTS="findCoreMyButlerForLists";

	@SuppressWarnings("unchecked")
	@Override
	public List<CoreMyButler> findCoreMyButlerList() {
		return myBatisDAO.findForList(FIND_COREMYBUTLER_FOR_LISTS, null);
	}

	private static final String FIND_COREMYBUTLER_FOR_PAGES="findCoreMyButlerForPages";

	@SuppressWarnings("unchecked")
	@Override
	public Page<CoreMyButler> findCoreMyButlerPage(int pageNum, int pageSize, String crmbrName) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crmbrName", crmbrName);
		return myBatisDAO.findForPage(FIND_COREMYBUTLER_FOR_PAGES, new PageRequest(pageNum, pageSize, hashMap));
	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}